"""
配置管理相关路由
"""
from flask import Blueprint, jsonify, request
from services.system_service import system_service
from system.logger import Logger

config_bp = Blueprint('config', __name__, url_prefix='/api/system')
logger = Logger(root_dir=".", verbose_info=True, verbose_error=True)

@config_bp.route('/config')
def get_system_config():
    """获取系统配置"""
    return jsonify(system_service.get_config())

@config_bp.route('/config', methods=['POST'])
def update_system_config():
    """更新系统配置"""
    try:
        new_config = request.json
        system_service.update_config(new_config)
        logger.info("System configuration updated", config=str(new_config))
        return jsonify({'success': True, 'message': 'Configuration updated successfully'})
    except Exception as e:
        logger.error(f"Failed to update configuration: {str(e)}")
        return jsonify({'success': False, 'message': str(e)}), 500 